
var bi={
	/**
	renderPie.config属性说明
	elementId
	element
	title
	subtext
	labelFormatter
	data
	style
 	*/
	renderPie :function(config){
		var element=null;
		var st=config.style;
		if(!st){
			st=style;
		}
		if(!isNull(config.elementId)){
			element = echarts.init(document.getElementById(config.elementId), st);
		}else{
			element=config.element;
		}
		var option = {
				  title: {
				    text: config.title,
				    subtext: config.subtext,
				    left: 'center'
				  },
				tooltip: {
				    trigger: 'item'
				  },
				  legend: {
				    orient: 'vertical',
				    left: 'left'
				  },
			   series: [
			    {
			      type: 'pie',
			      radius: '50%',
			      data: config.data,
			      emphasis: {
			        itemStyle: {
			          shadowBlur: 10,
			          shadowOffsetX: 0,
			          shadowColor: 'rgba(0, 0, 0, 0.5)'
			        }
			      },
			      label: {
			        alignTo: 'edge',
			        formatter: config.labelFormatter,
			        minMargin: 5,
			        lineHeight: 15,
			        rich: {
			          time: {
			            fontSize: 10,
			            color: '#999'
			          }
			        }
			      },
			      labelLine: {
			        length: 15,
			        length2: 0,
			        maxSurfaceAngle: 80
			      },
			      labelLayout: function (params) {
			        const isLeft = params.labelRect.x < element.getWidth() / 2;
			        const points = params.labelLinePoints;
			        // Update the end point.
			        points[2][0] = isLeft
			          ? params.labelRect.x+params.labelRect.width
			          : params.labelRect.x ;
			        return {
			          labelLinePoints: points
			        };
			      }
			    }
			  ]
			};
		element.setOption(option,true);
	},
	/**
	renderBar.config属性说明
	elementId
	element
	title
	subtext
	labelFormatter
	series
	category 如果单独传了category，那data就直接去下面的data，否则data为{name:xxx,value:xxx}
	data
	style
 	*/
	renderBar :function(config){
		var st=config.style;
		if(!st){
			st=style;
		}
		var series=config.series;
		let category = [];
		if(config.category){
			category=config.category;
		}
		let data = [];
		if(!series){
			if(!category||category.length==0){
				var dd=config.data;
				for(var d in dd){
		　　　　　　　category.push(dd[d].name);
				     data.push(dd[d].value);
		　　　　 }
			}else{
				data=config.data;
			}
			series=[
			    {
			      data: data,
			      type: 'bar',
			      barGap: 0,
			      label: {
			        show: true,
			        position: 'top'
			      }
			    }
			];
		}
		var element=null;
		if(!isNull(config.elementId)){
			element = echarts.init(document.getElementById(config.elementId), st);
		}else{
			element=config.element;
		}
		var option = {
		 title: {
			    text: config.title,
			    subtext: config.subtext,
			    left: 'center'
			  },
		  tooltip: {
		    trigger: 'axis',
		    axisPointer: {
		      type: 'shadow'
		    }
		  },
		  xAxis: {
		    type: 'category',
		    data: category
		  },
		  yAxis: {
		    type: 'value'
		  },
		  grid: {
		    left: '3%',
		    right: '4%',
		    bottom: '3%',
		    containLabel: true
		  },
		  series: series
		};
		element.setOption(option,true);
	},
	/**
	renderLine.config属性说明
	elementId
	title
	subtext
	data
	series
	category:category数组[2021,2022,2023]
	legend:legend数组[a,b,c]
	data:data数组[[],[],[]]
	style
 	*/
	renderLine: function(config){
	var line = echarts.init(document.getElementById(config.elementId), config.style);
	option = {
		title: {
			text: config.title,
			subtext: config.subtext,
		},
		tooltip: {
		    trigger: 'axis',
		    axisPointer: {
		      type: 'cross'
		    }
		},
		legend: {
		},
		xAxis: {
			type: 'category',
			boundaryGap: false,
			data: config.category
		},
		yAxis: {
			type: 'value'
		},
	};
	var series = [];
	for (var i = 0; i < data.length; i++) {  
	 series[i]={
				name: config.legend[i],
				data: config.data[i],
				type: 'line',
				label: {
			        show: true,
			        position: 'top'
			      },
			};
	}
	option.series=series;
	line.setOption(option);
}
}
